package com.douqu.game.core.web.request;

import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.util.LogUtils;
import com.douqu.game.core.util.StringUtils;

public  class RechargeParam{
    private String objectIndex;
    private int rechargeId;
    private int serverId;
    private int lv;
    private int diamonds;
    private int ruleId;
    private String uniqueId;
    public String clientParam;
    private String outTradeNo;


    public RechargeParam() {
        this.uniqueId = ConstantFactory.PLACEHOLDER;
        this.clientParam = ConstantFactory.PLACEHOLDER;
    }

    public RechargeParam(String cbi) {
        try {
            String[] params = cbi.split(ConstantFactory.UNDERLINE);
            this.rechargeId = Integer.valueOf(params[1]);
            this.objectIndex = params[0];
            this.serverId = Integer.valueOf(params[2]);
            if(params.length > 3)
            {
                this.lv = Integer.valueOf(params[3]);
                this.diamonds = Integer.valueOf(params[4]);
                this.ruleId = Integer.valueOf(params[5]);
                this.uniqueId = ConstantFactory.PLACEHOLDER.equals(params[6]) ? null : params[6];
                this.clientParam = ConstantFactory.PLACEHOLDER.equals(params[7]) ? null : params[7];
                this.outTradeNo = params[8];
            }
        } catch (Exception e) {
            LogUtils.errorException(e);
            LogUtils.error("RechargeParam自定义参数解析错误:" + cbi);
        }
    }

    public String getObjectIndex() {
        return objectIndex;
    }

    public void setObjectIndex(String objectIndex) {
        this.objectIndex = objectIndex;
    }

    public int getRechargeId() {
        return rechargeId;
    }


    public int getServerId() {
        return serverId;
    }

    public void setRechargeId(int rechargeId) {
        this.rechargeId = rechargeId;
    }

    public void setServerId(int serverId) {
        this.serverId = serverId;
    }

    public String getUniqueId() {
        return uniqueId;
    }

    public void setUniqueId(String uniqueId) {
        this.uniqueId = uniqueId;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public String getClientParam() {
        if(StringUtils.isNullOrEmpty(clientParam)){
            return "";
        }
        if(ConstantFactory.PLACEHOLDER.equals(clientParam)){
            return "";
        }
        return clientParam;
    }

    public void setClientParam(String clientParam) {
            this.clientParam = clientParam;
        }

    public int getLv() {
        return lv;
    }

    public void setLv(int lv) {
        this.lv = lv;
    }

    public int getDiamonds() {
        return diamonds;
    }

    public void setDiamonds(int diamonds) {
        this.diamonds = diamonds;
    }

    public int getRuleId() {
        return ruleId;
    }

    public void setRuleId(int ruleId) {
        this.ruleId = ruleId;
    }

    @Override
    public String toString() {
        return "RechargeParam{" +
                "objectIndex='" + objectIndex + '\'' +
                ", rechargeId=" + rechargeId +
                ", serverId=" + serverId +
                ", lv=" + lv +
                ", diamonds=" + diamonds +
                ", ruleId=" + ruleId +
                ", uniqueId='" + uniqueId + '\'' +
                ", clientParam='" + clientParam + '\'' +
                ", outTradeNo='" + outTradeNo + '\'' +
                '}';
    }
}